/**
 * Copyright (c) 2005 - 2007 FeyaSoft Corp. All Rights Reserved.
 */
package com.feyaSoft.home.web.source;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.json.JSONArray;

/**
 * @author Fenqiang Zhuang
 * @Oct 8, 2007
 * 
 * This file is used to .....
 */
public class SourceJson {
	private List foldNames = new ArrayList();
	private List fileNames = new ArrayList();

	/**
	 * Return the value of fileNames
	 * 
	 * @return List - fileNames.
	 */
	public List getFileNames() {
		return fileNames;
	}

	/**
	 * Set the value of fileNames
	 * 
	 * @param CDRReportJson.java -
	 *            List.
	 */
	public void setFileNames(List fileNames) {
		this.fileNames = fileNames;
	}

	/**
	 * Return the value of foldNames
	 * 
	 * @return List - foldNames.
	 */
	public List getFoldNames() {
		return foldNames;
	}

	/**
	 * Set the value of foldNames
	 * 
	 * @param CDRReportJson.java -
	 *            List.
	 */
	public void setFoldNames(List foldNames) {
		this.foldNames = foldNames;
	}

	public JSONArray toJSONObject() throws Exception {
		// JSONObject json = new JSONObject();

		JSONArray jsonItems = new JSONArray();
		if (fileNames.size() > 0) {
			for (Iterator iter = fileNames.iterator(); iter.hasNext();) {
				DirFile file = (DirFile) (iter.next());
				jsonItems.put(file.toJSONObject());
			}
		}
		if (foldNames.size() > 0) {
			for (Iterator iter = foldNames.iterator(); iter.hasNext();) {
				Fold fold = (Fold) (iter.next());
				jsonItems.put(fold.toJSONObject());
			}
		}

		return jsonItems;
	}
}
